const { query } = require("../db/query")
module.exports = {
  setUserList: async (user_id, cover_user_id, user_name, user_avatar, cover_user_name, cover_user_avatar, content, createtime) => {
    // 调用query发送sql语句到mysql进行注册用户
    return await query("insert into chat_list(user_id, cover_user_id, user_name, user_avatar, cover_user_name, cover_user_avatar, content, createtime) values(?,?,?,?,?,?,?,?)", [user_id, cover_user_id, user_name, user_avatar, cover_user_name, cover_user_avatar, content, createtime])
  },
  queryUser: async (user_id) => {
    // 调用query发送sql语句到mysql进行注册用户
    return await query("select * from chat_list where user_id =? or cover_user_id =? order by createtime asc", [user_id, user_id])
  },
  queryUserOfUser: async (user_id, cover_user_id) => {
    // 调用query发送sql语句到mysql进行注册用户
    return await query("select * from chat_list where user_id =? and cover_user_id =?", [user_id, cover_user_id])
  },
  queryUserOfCoverUser: async (user_id, cover_user_id) => {
    // 调用query发送sql语句到mysql进行注册用户
    return await query("select * from chat_list where user_id =? and cover_user_id =?", [cover_user_id, user_id])
  },
  queryContent: async (user_id, cover_user_id) => {
    // 调用query发送sql语句到mysql进行注册用户
    return await query("select * from chat_content where user_id =? and cover_user_id =? or user_id =? and cover_user_id =? order by createtime asc", [user_id, cover_user_id, cover_user_id, user_id])
  },
  setUserContent: async (user_id, cover_user_id, user_name, user_avatar, content, createtime) => {
    // 调用query发送sql语句到mysql进行注册用户
    return await query("insert into chat_content(user_id, cover_user_id, user_name, user_avatar, content, createtime) values(?,?,?,?,?,?)", [user_id, cover_user_id, user_name, user_avatar, content, createtime])
  },
}